package com.adapters;

import java.util.List;

import com.Gourmet.Activities.R;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.RatingBar;
import android.widget.TextView;



public class CustomAdapter extends ArrayAdapter<RowData>{
	
	private LayoutInflater mInflater;
	private Integer[] imgid = null;
	
	public CustomAdapter(Context context, int resource,
              int textViewResourceId, List<RowData> objects, Integer[] imgid, LayoutInflater mInflater) {    
		
		super(context, resource, textViewResourceId, objects);
		this.imgid = imgid;
		this.mInflater = mInflater;
	}
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {   
		ViewHolder holder = null;
		TextView title = null;
		TextView detail = null;
		ImageView i11=null;
		RatingBar myRatingBar = null;   
		RowData rowData= getItem(position);
		
		if(null == convertView){
		  convertView = mInflater.inflate(R.layout.listarestauranes_list, null);
		  holder = new ViewHolder(convertView);
		  convertView.setTag(holder);
		}
		holder = (ViewHolder) convertView.getTag();
		title = holder.gettitle();
		title.setText(rowData.mTitle);
		detail = holder.getdetail();
		detail.setText(rowData.mDetail);  
   
		i11=holder.getImage();
		i11.setImageResource(imgid[rowData.mId]);
   
		myRatingBar=holder.getRatingBar();
		myRatingBar.setRating(rowData.rating);
   
		return convertView;
	}


}
